8  Extract Data form Calculation Result

This tutorial we get started with extracting infomations from calculation results.

library(lagci)
Warning in fun(libname, pkgname): mzR has been built against a different Rcpp version (1.0.14)
than is installed on your system (1.1.0). This might lead to errors
when loading mzR. If you encounter such issues, please send a report,
including the output of sessionInfo() to the Bioc support forum at 
https://support.bioconductor.org/. For details see also
https://github.com/sneumann/mzR/wiki/mzR-Rcpp-compiler-linker-issue.
── Attaching packages ────────────────────────────────────────── lagci 0.99.5 ──
✔ dplyr   1.1.4     ✔ ggplot2 3.5.2
── Conflicts ────────────────────────────────────────────── lagci_conflicts() ──
✖ methods::body<-()    masks base::body<-()
✖ dplyr::filter()      masks stats::filter()
✖ methods::kronecker() masks base::kronecker()
✖ dplyr::lag()         masks stats::lag()
data("heart_data")
data("step_data")
result <- lagci::calculate_lagged_correlation(
  x = heart_data$heart,
  y = step_data$step,
  time1 = heart_data$time,
  time2 = step_data$time,
  time_tol = 0.5,
  step = 1/60,
  align_method = "linear",
  cor_method = "spearman"
)

8.1 extract_shift_time

shift_time_numeric <- extract_shift_time(object = result,numeric = TRUE)
shift_time_numeric
 [1] -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11
[20] -10  -9  -8  -7  -6  -5  -4  -3  -2  -1   0   1   2   3   4   5   6   7   8
[39]   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27
[58]  28  29
shift_time <- extract_shift_time(object = result,numeric = FALSE)
shift_time
 [1] "(-29.5,-28.5]" "(-28.5,-27.5]" "(-27.5,-26.5]" "(-26.5,-25.5]"
 [5] "(-25.5,-24.5]" "(-24.5,-23.5]" "(-23.5,-22.5]" "(-22.5,-21.5]"
 [9] "(-21.5,-20.5]" "(-20.5,-19.5]" "(-19.5,-18.5]" "(-18.5,-17.5]"
[13] "(-17.5,-16.5]" "(-16.5,-15.5]" "(-15.5,-14.5]" "(-14.5,-13.5]"
[17] "(-13.5,-12.5]" "(-12.5,-11.5]" "(-11.5,-10.5]" "(-10.5,-9.5]" 
[21] "(-9.5,-8.5]"   "(-8.5,-7.5]"   "(-7.5,-6.5]"   "(-6.5,-5.5]"  
[25] "(-5.5,-4.5]"   "(-4.5,-3.5]"   "(-3.5,-2.5]"   "(-2.5,-1.5]"  
[29] "(-1.5,-0.5]"   "(-0.5,0.5]"    "(0.5,1.5]"     "(1.5,2.5]"    
[33] "(2.5,3.5]"     "(3.5,4.5]"     "(4.5,5.5]"     "(5.5,6.5]"    
[37] "(6.5,7.5]"     "(7.5,8.5]"     "(8.5,9.5]"     "(9.5,10.5]"   
[41] "(10.5,11.5]"   "(11.5,12.5]"   "(12.5,13.5]"   "(13.5,14.5]"  
[45] "(14.5,15.5]"   "(15.5,16.5]"   "(16.5,17.5]"   "(17.5,18.5]"  
[49] "(18.5,19.5]"   "(19.5,20.5]"   "(20.5,21.5]"   "(21.5,22.5]"  
[53] "(22.5,23.5]"   "(23.5,24.5]"   "(24.5,25.5]"   "(25.5,26.5]"  
[57] "(26.5,27.5]"   "(27.5,28.5]"   "(28.5,29.5]"  

8.2 extract_all_cor

all_cor <- extract_all_cor(object = result)
all_cor
(-29.5,-28.5] (-28.5,-27.5] (-27.5,-26.5] (-26.5,-25.5] (-25.5,-24.5] 
    0.1859900     0.1879001     0.1918063     0.1955183     0.2012986 
(-24.5,-23.5] (-23.5,-22.5] (-22.5,-21.5] (-21.5,-20.5] (-20.5,-19.5] 
    0.2098186     0.2166331     0.2253865     0.2311008     0.2335685 
(-19.5,-18.5] (-18.5,-17.5] (-17.5,-16.5] (-16.5,-15.5] (-15.5,-14.5] 
    0.2366713     0.2398249     0.2455481     0.2523574     0.2597611 
(-14.5,-13.5] (-13.5,-12.5] (-12.5,-11.5] (-11.5,-10.5]  (-10.5,-9.5] 
    0.2661878     0.2737553     0.2844844     0.2987540     0.3095692 
  (-9.5,-8.5]   (-8.5,-7.5]   (-7.5,-6.5]   (-6.5,-5.5]   (-5.5,-4.5] 
    0.3197012     0.3341143     0.3523894     0.3715656     0.3926565 
  (-4.5,-3.5]   (-3.5,-2.5]   (-2.5,-1.5]   (-1.5,-0.5]    (-0.5,0.5] 
    0.4143358     0.4357658     0.4614099     0.4919202     0.5338049 
    (0.5,1.5]     (1.5,2.5]     (2.5,3.5]     (3.5,4.5]     (4.5,5.5] 
    0.5795711     0.5887494     0.5670783     0.5394754     0.5104598 
    (5.5,6.5]     (6.5,7.5]     (7.5,8.5]     (8.5,9.5]    (9.5,10.5] 
    0.4807723     0.4595860     0.4410825     0.4227621     0.4026052 
  (10.5,11.5]   (11.5,12.5]   (12.5,13.5]   (13.5,14.5]   (14.5,15.5] 
    0.3860908     0.3756305     0.3663601     0.3556953     0.3461169 
  (15.5,16.5]   (16.5,17.5]   (17.5,18.5]   (18.5,19.5]   (19.5,20.5] 
    0.3354512     0.3258274     0.3161798     0.3061992     0.2994837 
  (20.5,21.5]   (21.5,22.5]   (22.5,23.5]   (23.5,24.5]   (24.5,25.5] 
    0.2943537     0.2886603     0.2862754     0.2803777     0.2725397 
  (25.5,26.5]   (26.5,27.5]   (27.5,28.5]   (28.5,29.5] 
    0.2665251     0.2629308     0.2625087     0.2615348 

8.3 extract_all_cor_p

all_cor_p <- extract_all_cor_p(object = result)
all_cor_p
(-29.5,-28.5] (-28.5,-27.5] (-27.5,-26.5] (-26.5,-25.5] (-25.5,-24.5] 
            0             0             0             0             0 
(-24.5,-23.5] (-23.5,-22.5] (-22.5,-21.5] (-21.5,-20.5] (-20.5,-19.5] 
            0             0             0             0             0 
(-19.5,-18.5] (-18.5,-17.5] (-17.5,-16.5] (-16.5,-15.5] (-15.5,-14.5] 
            0             0             0             0             0 
(-14.5,-13.5] (-13.5,-12.5] (-12.5,-11.5] (-11.5,-10.5]  (-10.5,-9.5] 
            0             0             0             0             0 
  (-9.5,-8.5]   (-8.5,-7.5]   (-7.5,-6.5]   (-6.5,-5.5]   (-5.5,-4.5] 
            0             0             0             0             0 
  (-4.5,-3.5]   (-3.5,-2.5]   (-2.5,-1.5]   (-1.5,-0.5]    (-0.5,0.5] 
            0             0             0             0             0 
    (0.5,1.5]     (1.5,2.5]     (2.5,3.5]     (3.5,4.5]     (4.5,5.5] 
            0             0             0             0             0 
    (5.5,6.5]     (6.5,7.5]     (7.5,8.5]     (8.5,9.5]    (9.5,10.5] 
            0             0             0             0             0 
  (10.5,11.5]   (11.5,12.5]   (12.5,13.5]   (13.5,14.5]   (14.5,15.5] 
            0             0             0             0             0 
  (15.5,16.5]   (16.5,17.5]   (17.5,18.5]   (18.5,19.5]   (19.5,20.5] 
            0             0             0             0             0 
  (20.5,21.5]   (21.5,22.5]   (22.5,23.5]   (23.5,24.5]   (24.5,25.5] 
            0             0             0             0             0 
  (25.5,26.5]   (26.5,27.5]   (27.5,28.5]   (28.5,29.5] 
            0             0             0             0 

8.4 extract_max_cor

max_cor <- extract_max_cor(object = result)
max_cor
(1.5,2.5] 
0.5887494 

8.5 extract_global_cor

global_cor <- extract_global_cor(object = result)
global_cor
(-0.5,0.5] 
 0.5338049